package com.example.devimpact.controller;

import com.example.devimpact.entity.User;
import com.example.devimpact.service.UserService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/users")
@Tag(name = "用户管理", description = "用户相关的管理接口")
public class UserController {
    
    @Autowired
    private UserService userService;
    
    @GetMapping
    @Operation(summary = "获取所有用户", description = "获取系统中所有的用户信息")
    public List<User> getAllUsers() {
        return userService.getAllUsers();
    }
    
    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取用户", description = "根据用户ID获取特定用户的信息")
    public User getUserById(@PathVariable Long id) {
        return userService.getUserById(id);
    }
    
    @PostMapping
    @Operation(summary = "创建新用户", description = "创建一个新的用户")
    public User createUser(@RequestBody User user) {
        return userService.saveUser(user);
    }
}
